package gen.tools.svn;


import gen.tools.Widgets;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ChkSVNconnection extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ChkSVNconnection() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		final Widgets wid = new Widgets();
		request.setCharacterEncoding( wid.UIcodeSet );
		response.setCharacterEncoding( wid.UIcodeSet );
		response.setContentType("application/text");
		
		/*
		 * 0 尚未測試	
		 * 2 主機不能連
		 * 3 帳密不通
		 * 4 連線正常
		 * */
		int resSVN4subsys = 0;	
		
		final String url = request.getParameter("url");	//連線位址
		final String usr = request.getParameter("usr");	//登入帳號
		final String pwd = request.getParameter("pwd");	//登入密碼
		
		try {
			resSVN4subsys = wid.chkSVNconnection(url,usr,pwd);
		} catch (Exception e) {
			wid.errLog(e);
		}
		response.getWriter().write( String.valueOf(resSVN4subsys) );
	}
}
